add_compile_definitions(ASIO_STANDALONE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
	add_compile_definitions(_WIN32_WINNT=0x0501)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    link_libraries(pthread)
endif()

macro(add_target target_name)
    file(GLOB_RECURSE source_files 	"${CMAKE_CURRENT_SOURCE_DIR}/${target_name}.cpp" "${PROJECT_SOURCE_DIR}/*.editorconfig")
    group_src_by_dir(source_files)
    add_executable(${target_name} ${source_files})
    set_target_properties(${target_name} PROPERTIES DEBUG_POSTFIX "_d")
    set_target_properties(${target_name} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../bin)
    set_target_properties(${target_name} PROPERTIES FOLDER EchoDemo)
endmacro(add_target)


add_target(async_tcp_echo_server)
add_target(async_udp_echo_server)
add_target(blocking_tcp_echo_client)
add_target(blocking_tcp_echo_server)
add_target(blocking_udp_echo_client)
add_target(blocking_udp_echo_server)